const fs = require("fs");
const readline = require("readline");
const path = require("path");
// const file = path.resolve(__dirname, "../w3c/week1/1_2/1_2_1/1.md");

const glob = require("glob");
const delList = glob.sync(`../w3c/**/*.out.md`);
delList.forEach(v => {
  console.log('rm',v)
  fs.unlinkSync(v)
})

const list = glob.sync(`../w3c/**/*.md`);
console.log("list", list);
list.forEach((v) => delComment(v));

async function delComment(file) {
  const input = fs.createReadStream(file);
  let output = [];
  const rl = readline.createInterface({
    input: input,
    crlfDelay: Infinity,
  });

  for await (const line of rl) {
    let isComment = line.indexOf("> ") === 0;
    // !isComment && console.log(line);
    !isComment && output.push(line + "\n");
  }
  fs.writeFileSync(file + ".out.md", output.join(""));
}

// delComment(file)
//
